n=int(input())
arr=list(map(int,input().split()))

def getResult():
    arr.sort()
    fault=res=minApple=arr[0]
    for i in range(1,len(arr)):
        tmp=arr[i]
        fault=fault^tmp
        res=res+tmp

    if fault==0:
        return res-minApple
    else:
        return -1
"输入值"
# 8
# 7258 6579 2602 6716 3050 3564 5396 1773
# 35165
print(getResult())